package com.it.service;

import com.it.mapper.StudentMapper;
import com.it.pojo.PageBean;
import com.it.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public PageBean<Student> queryAllService(int index, int size) {
        Integer i = index > 1 ? Integer.valueOf((index - 1) + "0") : (index - 1);
        List<Student> students = studentMapper.queryAllMapper(i, size);
        PageBean<Student> pageBean = new PageBean<>();
        pageBean.setCurrentPage(index);
        pageBean.setPageSize(size);
        pageBean.setData(students);
        return pageBean;
    }

    public List<Student> queryAgeService(int ageNum) {
        return studentMapper.qyeryAgeMapper(ageNum);
    }

    public List<Student> queryGenderService(String genderNum) {
        return studentMapper.qyeryGenderMapper(genderNum);
    }

    public int addstuService(Student student) {
        return studentMapper.addStuMapper(student);
    }

    public int delstuService(int id) {
        return studentMapper.delStuMapper(id);
    }

    public int putstuService(Student student) {
        return studentMapper.putStuMapper(student);
    }

}
